package leetcode.weekly.week322;

//Solution1Test
public class Solution1 {

	public boolean isCircularSentence(String sentence) {
		String[] words = sentence.split(" ");
		if (words.length == 1) {
			return words[0].charAt(0) == words[0].charAt(words[0].length() - 1);
		}
		if (words[0].charAt(0) != words[words.length - 1].charAt(words[words.length - 1].length() - 1)) {
			return false;
		}
		for (int i = 1; i < words.length; i++) {
			String f = words[i - 1];
			String s = words[i];
			if (f.charAt(f.length() - 1) != s.charAt(0)) {
				return false;
			}
		}
		return true;
	}
}
